package com.ruoyi.develop.factory.factoryProducePlanGongxu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryProducePlanGongxu.domain.FactoryProducePlanGongxu;
import com.ruoyi.develop.factory.factoryProducePlanGongxu.service.IFactoryProducePlanGongxuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排产计划工单关联的工序信息Controller
 * @author qh
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/factoryProducePlanGongxu/factoryProducePlanGongxu")
public class FactoryProducePlanGongxuController extends BaseController {
    @Autowired
    private IFactoryProducePlanGongxuService factoryProducePlanGongxuService;

    /**
     * 查询排产计划工单关联的工序信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryProducePlanGongxu entity) {
        startPage();
        List<FactoryProducePlanGongxu> list = factoryProducePlanGongxuService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出排产计划工单关联的工序信息列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:export')")
    @Log(title = "排产计划工单关联的工序信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryProducePlanGongxu entity) {
        List<FactoryProducePlanGongxu> list = factoryProducePlanGongxuService.selectList(entity);
        ExcelUtil<FactoryProducePlanGongxu> util = new ExcelUtil<FactoryProducePlanGongxu>(FactoryProducePlanGongxu. class);
        util.exportExcel(response, list, "排产计划工单关联的工序信息数据");
    }

    /**
     * 获取排产计划工单关联的工序信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryProducePlanGongxuService.selectById(id));
    }

    /**
     * 新增排产计划工单关联的工序信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:add')")
    @Log(title = "排产计划工单关联的工序信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryProducePlanGongxu entity) {
        return toAjax(factoryProducePlanGongxuService.insert(entity));
    }

    /**
     * 修改排产计划工单关联的工序信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:edit')")
    @Log(title = "排产计划工单关联的工序信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryProducePlanGongxu entity) {
        return toAjax(factoryProducePlanGongxuService.update(entity));
    }

    /**
     * 删除排产计划工单关联的工序信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProducePlanGongxu:remove')")
    @Log(title = "排产计划工单关联的工序信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryProducePlanGongxuService.deleteByIds(ids));
    }
}
